<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Insert title here</title>
	</head>
	<body>
	<h:form id="formAnswer">
		<a4j:keepAlive beanName="respostaBean"></a4j:keepAlive>
		<h:messages id="mensagens" globalOnly="true"></h:messages>
		<h2><h:outputText id="lbPergunta"
			value="#{respostaBean.pergunta.titulo}" /></h2>
		<br />
		<h4><h:outputText
			value="#{respostaBean.pergunta.quantidadeRespostas} Resposta(s)" />
		</h4>
		<hr />
		<a4j:repeat id="list" value="#{respostaBean.pergunta.respostas}"
			var="item">
			<li>

			<p><h:outputText value="Melhor Resposta ! "
				rendered="#{item.melhorResposta}" /> <h:outputText
				value="#{item.descricao}" escape="false" class="entry" /></p>
			</li>
			<li>
			<p class="postmetadata"><a4j:commandButton value="aprova"
				immediate="true" action="#{respostaBean.aprovarResposta}"
				reRender="formAnswer" enable="#{respostaBean.naoAprovada}">
				<f:setPropertyActionListener value="#{item.id}"
					target="#{respostaBean.idEntity}" />
			</a4j:commandButton>| <a4j:commandButton value="desaprova" immediate="true"
				enable="#{respostaBean.jaAprovada}"
				action="#{respostaBean.desaprovarResposta}" reRender="formAnswer" />|

			<a4j:commandButton value="melhor resposta" immediate="true"
				rendered="#{respostaBean.perguntaOwner}"
				action="#{respostaBean.classificarMelhor}" reRender="formAnswer" /></p>
			</li>
		</a4j:repeat>
		<br />
			Responder
			<br />
		<rich:editor value="#{respostaBean.resposta.descricao}"
			theme="advanced" required="true" requiredMessage="Campo obrigatório" />

		<br />
		<a4j:commandButton action="#{respostaBean.submitAnswer}"
			reRender="formAnswer" value="Salvar" />
	</h:form>
	</body>
</ui:composition>